import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by lenovo on 2018/5/22.
 */
public class Funds extends JFrame implements ActionListener {

    JPanel title, main;
    JButton add, aqq, re;
    User user;

    public Funds(User u) {
        this.setLayout(new BorderLayout());//网格式布局
        user = u;
        title = new JPanel();
        main = new JPanel();
        title.setLayout(new FlowLayout(FlowLayout.CENTER,0,25));
        title.setPreferredSize(new Dimension( 300, 60));
        add = new JButton("充值");
        aqq = new JButton("提现");
        re = new JButton("返回");

        add.addActionListener(this);
        aqq.addActionListener(this);
        re.addActionListener(this);

        title.add(new JLabel("剩余金额：" + u.getMoney()));
        main.add(add);
        main.add(aqq);
        main.add(re);
        main.setPreferredSize(new Dimension(300,50));


        this.add(title,BorderLayout.NORTH);
        this.add(main,BorderLayout.CENTER);
        this.setSize(300, 150);
        this.setLocationRelativeTo(null);//在屏幕中间显示(居中显示)

        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);//退出关闭JFrame
        this.setTitle("资金管理");//窗体标签
        this.setVisible(true);
        this.setResizable(false);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand() == "充值") {
            new In(user);
            this.dispose();
        }
        if (e.getActionCommand() == "提现") {
            new Out(user);
            this.dispose();
        }
        if (e.getActionCommand() == "返回") {
            new Home(user);
            this.dispose();
        }
    }
}
